home *** CD-ROM | disk | FTP | other *** search
/ Oh!X 2000 Spring / Oh!X 2000 Spring Special CD-ROM (Japan) (Part 2).7z / Oh!X 2000 Spring Special CD-ROM (Japan) (Part 2).bin / DXF / samples / multimedia / dplay / src / duel / util.cpp < prev   
C/C++ Source or Header  |  1999-03-09  |  2KB  |  65 lines

  1. //-----------------------------------------------------------------------------
  2. // File: Util.cpp
  3. //
  4. // Desc: Misc routines
  5. //
  6. // Copyright (C) 1995-1999 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #include "duel.h"
  9. #include <stdlib.h>
  10.  
  11.  
  12.  
  13.  
  14. //-----------------------------------------------------------------------------
  15. // Name: randInt()
  16. // Desc: Returns a random integer in the specified range
  17. //-----------------------------------------------------------------------------
  18. int randInt( int low, int high )
  19. {
  20.     int range = high - low;
  21.     int num = rand() % range;
  22.     return( num + low );
  23. }
  24.  
  25.  
  26.  
  27.  
  28. //-----------------------------------------------------------------------------
  29. // Name: randDouble()
  30. // Desc: Returns a random double in the specified range
  31. //-----------------------------------------------------------------------------
  32. double randDouble( double low, double high )
  33. {
  34.     double range = high - low;
  35.     double num = range * (double)rand()/(double)RAND_MAX;
  36.     return( num + low );
  37. }
  38.  
  39.  
  40.  
  41.  
  42. //-----------------------------------------------------------------------------
  43. // Name: dtrace()
  44. // Desc: Diagnostic trace to OutputDebugString() (UNICODE supported)
  45. //-----------------------------------------------------------------------------
  46. VOID dtrace( TCHAR* strFormat, ... )
  47. {
  48.     int     offset = 0;
  49.     TCHAR   strBuf[256];
  50.     va_list ap;
  51.  
  52.     va_start( ap, strFormat );
  53.  
  54.     offset = wsprintf( strBuf, TEXT("DUEL: ") );
  55.     offset += wvsprintf( strBuf+offset, strFormat, ap );
  56.  
  57.     OutputDebugString( strBuf );
  58.  
  59.     va_end( ap );
  60. }
  61.  
  62.  
  63.  
  64.  
  65.